
#if 0

#include <cassert>
#include <iostream>
using namespace std;

#include "tools/document/widget.h"

namespace tools{

    namespace{

        typedef Form::Str 
            Str;
        typedef Form::ListStr
            ListStr;
        typedef Form::Forms
            Forms;
        typedef Form::PForm
            PForm;
        typedef Form::CPForm
            CPForm;

    }//namespace

    Str Form::Deep(const size_t d,const Ch ch){ return Str(d*2,ch); }
//-----------------------------------------------------------------------
    const Form& Form::View()const
    {
        cout << AboutMe()<<endl;
        return *this;
    }
//-----------------------------------------------------------------------
    Form::Form(const Form& rhs)
        :mData(rhs.mData)
    {
        cout<<"Form: copy from '"<<rhs.mData->mName<<"'\n";
    }
    Form::Form(const Form&& rhs)
        :mData(::std::move(rhs.mData) )
    {
        cout<<"Form: copy rvalue from '"<<rhs.mData->mName<<"'\n";
    }
    Form::Form(const Str& name, Form* parent)
        :mData( ::std::make_shared<FormData>(name, parent) )
    {
        mData.operator->();
        cout<<"Form: default by name '"<<mData->mName<<"'\n";
    }
//-----------------------------------------------------------------------
    const Str& Form::GetName()const { return mData->mName; }

    Form& Form::Close()
    {
        if(mData->mParent)
            return *mData->mParent;
        return *this;
    }
    Form& Form::Close(const Str& tag)
    {
        if(!tag.empty())
            mData->mClose = tag;
        return Close();
    }
//-----------------------------------------------------------------------
    Str Form::AboutMe()const { return AboutMe(0); }
    Str Form::AboutMe(const size_t d)const 
    {
        Str info = Deep(d) + mData->mName+'\n';
        for(const auto& i: mData->mContent)
            info+= i->AboutMe(d+1) +'\n';
        if(!mData->mClose.empty())
            info +=Deep(d) + mData->mClose;
        else
            info.pop_back();
        return info;
    }
//-----------------------------------------------------------------------
    CPForm Form::Find(const Str& name)const
    {
        if(mData->mName==name)
            return shared_from_this();
        for(const auto& i: mData->mContent)
            if( CPForm p = i->Find(name) )
                return p;
        return CPForm();
    }
    PForm Form::Find(const Str& name)
    {
        if(mData->mName==name)
            return shared_from_this();
        for(const auto& i: mData->mContent)
            if( PForm p = i->Find(name) )
                return p;
        return PForm();
    }
//-----------------------------------------------------------------------
//     PForm Form::Cut(const Str& name)const
//     {
//         const bool ERROR_ILLEGAL_CUT_ROOT_FORM = mData->mName==name;
//         assert(!ERROR_ILLEGAL_CUT_ROOT_FORM);
// 
// //         if(mData->mName==name)
// //             return shared_from_this();
// 
//         for(const auto& i: mData->mContent)
//             if( PForm p = i->Find(name) )
//                 return p;
//         return CPForm();
//     }

#if 0
    PForm Form::Cut(const PForm& f)const
    {
        Form* parent = f->mData->mParent;

        const bool ERROR_ILLEGAL_CUT_ROOT_FORM = !parent;
        assert(!ERROR_ILLEGAL_CUT_ROOT_FORM);

        auto& con = parent->mData->mContent;
        auto it = find( con.begin(),  con.end(), f );

        const bool INTERNAL_ERROR_CHILD_FORM_NOT_FOUNDED = it==con.end();
        assert(!INTERNAL_ERROR_CHILD_FORM_NOT_FOUNDED);

        const auto re = con.erase(it);
        if(re==con.end())
           return parent->shared_from_this();
        return *re;
    }
#endif

    


}//namespace tools





#if 0

//---------------------------------------------------------------

    
    Form* Form::Find(const Str& name)
    {
        return const_cast<Form*>
            ( const_cast<const Form*>(this)->Find(name) );
    }

   


    void Form::Insert(const Str& name,const Form& f)const
    {
//         Form* parent = f.mParent;
//         if(!parent)
//             return ;

        const Form* s = Find(name);
        if(!s)
            return;

        Form* parent = s->mParent;
        if(!parent)
            return;

        Form* ff = const_cast<Form*>(&f);
        parent->mContent.emplace_front(ff);


        
//         auto& con = parent->mContent;
//         auto it = find( con.begin(),  con.end(), &f );
//         if(it==con.end())
//             return ;
        //con.insert(it,&f);
    }

}//namespace tools

#endif

#endif
